<?php

namespace App\Http\Controllers\Admin\Meeting;

use App\Http\Controllers\Admin\BaseController;
use App\Http\Controllers\Controller;
use App\Models\MeetingActivity;
use Illuminate\Http\Request;

class ActivityController extends BaseController
{
    public function get(Request $request)
    {
        $activity = MeetingActivity::find($request->input('id'));
        return ajaxReturn(['activity' => $activity]);
    }

    public function batchget(Request $request){
        $query = MeetingActivity::query();
        return ajaxReturn([
            'total'=>$query->count(),
            'items'=>$query->offset($request->input('offset',0))
            ->limit($request->input('count',10))->get()
        ]);
    }

    public function save(Request $request){
        $activity = MeetingActivity::findOrNew($request->input('id'));
        $activity->fill($request->input('activity',[]))->save();
        return ajaxReturn(['activity' => $activity]);
    }

    public function delete(Request $request){
        MeetingActivity::whereKey($request->input('items',[]))->delete();
        return ajaxReturn();
    }
}
